package com.elitesland.system.entity;

import com.elitesland.core.base.BaseModel;
import com.elitesland.system.annotation.Comment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Objects;

/**
 * @author mir
 * @date
 */
@Entity
@Table(name = "sys_user_role")
@org.hibernate.annotations.Table(appliesTo = "sys_user_role", comment = "用户角色关联表")
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "用户角色关联表", description = "用户角色关联表")
public class SysUserRoleDO extends BaseModel implements Serializable {
    private static final long serialVersionUID = -8777065721688751524L;

    @ApiModelProperty(value = "用户ID")
    @Comment("用户ID")
    @Column()
    Long userId;

    @ApiModelProperty(value = "角色ID")
    @Comment("角色ID")
    @Column()
    Long roleId;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof SysUserRoleDO)) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        SysUserRoleDO entity = (SysUserRoleDO) o;
        return getId().equals(entity.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId());
    }
}